<%--
  Created by IntelliJ IDEA.
  User: DELL
  Date: 2021-11-11
  Time: 16:21
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>测试环境</title>
    <%
        String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort() + request.getContextPath();
    %>
    <base href="<%=basePath+"/"%>"/>
    <script type="text/javascript" src="js/jquery-3.5.1.js"></script>
    <script>
        $(function (){
            $("#but1").click(function (){
                $.ajax({
                    url:"test3",
                    dataType:"json",
                    success:function (data){
                        // alert(data.s1.name);
                        // $("#a1").html(data);
                        $.each(data,function (i,n){
                            $("#tb").append("<tr>").
                            append("<td>"+n.name+"</td>").
                            append("<td>"+n.age+"</td></tr>");
                        })
                    }
                })
            })
        })
    </script>
</head>
<body>
    <button id="but1">发送ajax</button>
    <table>
        <thead>
            <tr>
                <th>姓名</th>
                <th>年龄</th>
            </tr>
        </thead>
        <tbody id="tb">

        </tbody>
    </table>
</body>
</html>
